import request from '@/utils/request'
import { renderUrl } from '../utils'

const headers = {
  'Content-Type': 'application/json'
}

export function add(data) {
  return request({
    url: '/coupon/add',
    method: 'POST',
    data: JSON.stringify(data),
    headers
  })
}

export function edit(data) {
  return request({
    url: '/coupon/update',
    method: 'POST',
    data: JSON.stringify(data),
    headers
  })
}

export function del(data) {
  return request({
    url: renderUrl('/coupon/delete/{id}', data),
    method: 'POST'
  })
}

export function getCouponDetail(data) {
  return request({
    url: renderUrl('/coupon/{id}', data),
    method: 'get'
  })
}

export function getwalletuserdeductOfSupply(data) {
  return request({
    url: '/admin/wallet/deductOfSupply',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export function grant(data) {
  return request({
    url: '/coupon/couponHistory/grant',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export default { add, edit, del,getwalletuserdeductOfSupply }
